package com.cci.zkweb.core.controller;

import java.util.Map;

import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.util.Initiator;

import com.cci.zkweb.core.entity.SessionItem;
import com.cci.zkweb.core.services.AuthenticationService;
import com.cci.zkweb.core.services.impl.AuthenticationServiceImpl;

public class AuthenticationInit 
implements Initiator {

	//services
	AuthenticationService authService = new AuthenticationServiceImpl();

	public void doInit(Page page, Map<String, Object> args) throws Exception {
		SessionItem si = authService.getUserSessionInfo();
		if(si == null || si.isAnonymous()) {
			Executions.sendRedirect("/pages/login.zul");
			return;
		}
	}
}